<template>
	<view>
		<view class="container" v-if="showFlag">
			<view class="orderTime borderBottom1">
				<text>预约时间</text>
				<text>{{ detail.order.yuyuedate }} {{ detail.order.yuyuetime=='am'?'上午':'下午' }} {{type!=1?detail.order.starthour+'点-'+detail.order.endhour+'点':''}}</text>
			</view>
			<view class="orderTime borderBottom10">
				<text>科目</text>
				<text>{{ detail.order.subjectstitle }}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>{{type==1?'练习圈数':'练习时长'}}</text>
				<text>{{ detail.order.yuyuenumber || detail.order.yuyueclasshour }}{{type==1?'圈':'小时'}}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>订单编号</text>
				<text>{{ detail.order.ordernumber }}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>订单状态</text>
				<text>{{ detail.order.statusname }}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>订单价格</text>
				<text>￥{{ detail.order.money }}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>使用积分</text>
				<text>{{ detail.order.integralmoney }}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>使用优惠券</text>
				<text>{{ detail.order.couponmoney }}</text>
			</view>
			<view class="orderTime ">
				<text>下单时间</text>
				<text>{{ detail.order.createtime }} </text>
			</view>
			<view class="borderBottom30">
				
			</view>
			<view class="teacherDetail borderBottom1">
				<text class="teacherDetail_text">教练信息</text>
				<view class="teacherDetail_info">
					<image :src="detail.coach.image" mode=""></image>
					<view class="teacherDetail_info_describe">
						<text>{{ detail.coach.name }}</text>
						<view class="phone" >{{ detail.coach.phone }}</view>
						<view class="content">
							<view class="trait" v-for="(item, index) in detail.coach.tags" :key="index">{{ item }}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="orderTime borderBottom1">
				<text>车辆型号</text>
				<text>{{detail.coach.car_model}}</text>
			</view>
			<view class="orderTime borderBottom1">
				<text>车牌号</text>
				<text>{{detail.coach.car_number}}</text>
			</view>
			<view class="introduce borderBottom30">
				<text class="introduce_title">车检信息</text>
				<view class="teacherMsg"><text style="word-break: break-word;">{{detail.coach.car_check}}</text></view>
			</view>
			<view class="fieldMsg">
				<text>场地信息</text>
				<view class="fieldMsg_area">
					<text>位置</text>
					<view class="" @tap="openMap">
						<image src="../../../static/img/teacherDetails/address.png" mode=""></image>
						<text>{{area.school_name}}</text>
					</view>
				</view>
				<view class="fieldMsg_time">
					<text>营业时间</text>
					<view class="">
						<image src="../../../static/img/teacherDetails/time.png" mode=""></image>
						<text>{{area.openingtime}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { orderDetail } from '@/api/user/myOrder/myOrder.js';
import { testOrderDetail } from '@/api/user/myOrder/testOrder.js';
export default {
	data() {
		return {
			area: {
				// latitude: 30.595556,
				// longitude: 104.063323,
				// name: '成都市武侯区蜀安驾校场地',
				// address: '成都市武侯区蜀安驾校场地'
			},
			detail: {},
			showFlag: false,
			type:1,
		};
	},
	async onLoad(options) {
		console.log(options);
		this.type=options.type
		let res;
		if(options.type==1){
			res = await orderDetail(options.id);
		}else{
			res = await testOrderDetail(options.id);
		}
		res.data.coach.tags = res.data.coach.tags.split(',');
		res.data.changdi.lnglat=JSON.parse(res.data.changdi.lnglat)
		this.area=res.data.changdi
		this.detail = res.data;
		this.showFlag = true;
	},
	methods: {
		openMap() {
			uni.openLocation({
				latitude: this.area.lnglat.lat,
				longitude: this.area.lnglat.lng,
				name: this.area.school_name,
				address: this.area.school_name,
				success: function() {
					console.log('success');
				},
				fail: () => {
					console.log('fail');
				}
			});
		},
	}
};
</script>

<style lang="scss">
@import './css/orderDetail.scss';
</style>
